package cn.dapeng.jdk21;

public class CustomThread implements Runnable {

    private ThreadLocal<String> threadLocal;

    public ThreadLocal<String> getThreadLocal() {
        return threadLocal;
    }

    public CustomThread() {

    }

    public CustomThread(ThreadLocal<String> threadLocal) {
        this.threadLocal = threadLocal;
    }

    @Override
    public void run() {
        if (Thread.currentThread().getName().equals("")) {
            threadLocal.set("default");
        } else {
            threadLocal.set(Thread.currentThread().getName());
        }
        System.out.println("1. " + threadLocal.get() + " running ......");
    }
}
